package moe.collection;

import java.io.IOException;
import java.io.OutputStream;

import net.coobird.thumbnailator.ThumbnailParameter;
import net.coobird.thumbnailator.Thumbnails;
import net.coobird.thumbnailator.resizers.Resizers;
import net.coobird.thumbnailator.resizers.configurations.Rendering;

public class PreviewCreator {

	public static void createPreview(String path, String outFilepath, int width, int height)
			throws IOException {
		Thumbnails.of(path).resizer(Resizers.PROGRESSIVE).rendering(Rendering.DEFAULT)
				.size(width, height).imageType(ThumbnailParameter.ORIGINAL_IMAGE_TYPE)
				.toFile(outFilepath);
	}

	public static void realtimeConvert(String path, OutputStream os, int width, int height)
			throws IOException {
		Thumbnails.of(path).resizer(Resizers.PROGRESSIVE).rendering(Rendering.SPEED)
				.size(width, height).imageType(ThumbnailParameter.ORIGINAL_IMAGE_TYPE)
				.toOutputStream(os);
	}
}
